	var arr = ['static/images/0.png',
		'static/images/1.png',
		'static/images/2.png',
		'static/images/3.png',
		'static/images/4.png',
		'static/images/5.png',
		'static/images/6.png',
		'static/images/7.png',
		'static/images/8.png',
		'static/images/9.png',
		'static/images/mao.png']
		var panel =null;
		var aLi =null;
		var nTime = null;
		var str = null;
		var nstr;
  function showTime1() {
		var iNow = new Date();
		var nHours = iNow.getHours();
		var nMinutes = iNow.getMinutes();
		var nSecondes = iNow.getSeconds();
		str = toTwo(nHours) + ':' + toTwo(nMinutes) + ':' + toTwo(nSecondes);
	}
  function toTwo(n) {
  	return n < 10 ? '0' + n : '' + n;
  }

	function showTime2() {
		var iNow = new Date();
		nTime = iNow.getTime() + 1000;
		var iNew = new Date(nTime);
		var tHours = iNew.getHours();
		var tMinutes = iNew.getMinutes();
		var tSecondes = iNew.getSeconds();
		nstr = toTwo(tHours) + ':' + toTwo(tMinutes) + ':' + toTwo(tSecondes);
	}



	function initial(aLi) {
		for(var i = 0; i < aLi.length; i++) {
			if(i != 2 && i != 5) {
				aLi[i].getElementsByTagName("img")[0].src = arr[str.charAt(i)];
				aLi[i].getElementsByTagName("img")[1].src = arr[nstr.charAt(i)];
			} else {
				aLi[i].getElementsByTagName("img")[0].src = arr[10];
			}
		}
	}

	function timeRoll(obj, i) {
		setInterval(function() {
			var pNumber = str.charAt(i);
			var tNumber = nstr.charAt(i);
			var pImg = obj[i].getElementsByTagName("img")[0];
			var nImg = obj[i].getElementsByTagName("img")[1];
			if(pNumber !== tNumber && parseInt(getStyle(nImg, 'top')) == 92) {

				nImg.src = arr[nstr.charAt(i)];
				doMove(nImg, 'top', 5, 0, function() {

				});
				doMove(pImg, 'top', 5, -92, function() {
					pImg.style.top = '92px';
					pImg.src = arr[str.charAt(i)];

				});

			} else if(pNumber !== tNumber && parseInt(getStyle(pImg, 'top')) == 92) {

				pImg.src = arr[nstr.charAt(i)];
				doMove(pImg, 'top', 5, 0, function() {

				});
				doMove(nImg, 'top', 5, -92, function() {
					nImg.style.top = '92px';
					nImg.src = arr[str.charAt(i)];

				});
			}
		}, 1000)
	};
  function getStyle(obj, attr) {
  	return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj)[attr];
  }
  function doMove(obj, attr, dir, target, endFn) {
  	dir = parseInt(getStyle(obj, attr)) < target ? dir : -dir;
  	clearInterval(obj.timer);
  	obj.timer = setInterval(function() {
  		var speed = parseInt(getStyle(obj, attr)) + dir;
  		if(speed > target && dir > 0 || speed < target && dir < 0) {
  			speed = target; //往前跑
  		}
  		obj.style[attr] = speed + 'px';
  		if(speed == target) {
  			clearInterval(obj.timer);
  			endFn && endFn();
  		}
  	}, 30)
  }

  function shake(obj, attr, endFn) {
  	if(obj.onOff) {
  		return;
  	}
  	obj.onOff = true;
  	clearInterval(obj.shake);
  	var pos = parseInt(getStyle(obj, attr));
  	var arr = [];
  	var num = 0;
  	obj.shake = null;
  	for(var i = 10; i > 0; i -= 2) {
  		arr.push(i, -i);
  	}
  	arr.push(0);
  	obj.shake = setInterval(function() {
  		num = num % (arr.length)
  		obj.style[attr] = pos + arr[num] + "px";
  		num++;

  		if(num === arr.length) {
  			clearInterval(obj.shake);
  			endFn && endFn();
  			obj.onOff = false;
  		}
  	}, 50)
  }

  function opacity(obj, dir, target) {
  	// 判断当前的位置是不是大于目标点，小于dir就是正值，大于dir就是负值
  	dir = Number(getStyle(obj, 'opacity')) < target ? dir : -dir
  	// alert(dir)

  	clearInterval(obj.opaTimer);
  	obj.opaTimer = setInterval(function() {
  		var speed = Number(getStyle(obj, 'opacity')) + dir
  		// alert(speed)
  		if(speed < target && dir < 0 || speed > target && dir > 0) {
  			speed = target;
  		}
  		obj.style.opacity = speed;
  		// alert(speed)

  		if(speed === target) {
  			clearInterval(obj.opaTimer);

  		}
  	}, 100);
  }
export function time(){
  panel =document.getElementById("time-item");
  aLi =panel.getElementsByTagName("li");
  showTime1();
  showTime2();
  setInterval(function() {
  	showTime1();
  	showTime2();
  }, 1000);
  initial(aLi);
	timeRoll(aLi, 0);
	timeRoll(aLi, 1);
	timeRoll(aLi, 3);
	timeRoll(aLi, 4);
	timeRoll(aLi, 6);
	timeRoll(aLi, 7);
}

//转换成时间戳
const YyMmDdToTimes = (time) => {
	if(!time && time != 0) return ''
  return new Date(time.replace(/-/g, '/')).getTime()
}


const timesToYyMmDd1 = (times,geshi = 'YY-MM-DD HH:MM:SS')=>{//时间转换
	if(!times) return ''
  var d = new Date(times);
	let oTime = ''
	switch(geshi){
		case 'YY':
			oTime = d.getFullYear()
			break;
		case 'MM':
			oTime = d.getMonth() + 1
			break;
		case 'DD':
			oTime = d.getDate()
			break;
		case 'YY-MM':
			oTime = d.getFullYear() +
			'-' + (d.getMonth() + 1 >= 10 ?  d.getMonth() + 1 : '0' + (d.getMonth() + 1) )
			break;
		case 'YY-MM-DD':
			oTime = d.getFullYear() +
			'-' + (d.getMonth() + 1 >= 10 ?  d.getMonth() + 1 : '0' + (d.getMonth() + 1) ) +
			'-' + (d.getDate() >=10 ? d.getDate() : '0' + d.getDate() )
			break;
		case 'HH:MM:SS':
			oTime= (d.getHours() >=10 ? d.getHours() : '0' + d.getHours()) +
			':' + (d.getMinutes() >=10 ? d.getMinutes() : '0' + d.getMinutes()) +
			':' + (d.getSeconds() >=10 ? d.getSeconds() : '0' + d.getSeconds() );
			break;
		case 'YY-MM-DD HH:MM:SS':
			oTime= d.getFullYear() +
			'-' + (d.getMonth() + 1 >= 10 ?  d.getMonth() + 1 : '0' + (d.getMonth() + 1) ) +
			'-' + (d.getDate() >=10 ? d.getDate() : '0' + d.getDate() ) +
			' ' + (d.getHours() >=10 ? d.getHours() : '0' + d.getHours()) +
			':' + (d.getMinutes() >=10 ? d.getMinutes() : '0' + d.getMinutes()) +
			':' + (d.getSeconds() >=10 ? d.getSeconds() : '0' + d.getSeconds() );
			break;
	}
  return oTime
}

//获取当前日期几天后的数据
const getDay = (day) => {
  var today = new Date();
  var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  today.setTime(targetday_milliseconds); //注意，这行是关键代码

  var tYear = today.getFullYear();
   var tMonth = today.getMonth();
  var tDate = today.getDate();
   tMonth = doHandleMonth(tMonth + 1);
   tDate = doHandleMonth(tDate);
  return tYear + "-" + tMonth + "-" + tDate;
}

const doHandleMonth = (month) => {
var m = month;
if (month.toString().length == 1) {
   m = "0" + month;
 }
  return m;
}

// 0：00-23：59
//筛选条件开始时间和结束时间
const getEndStartTime = (dateRange) => {
  let startTime = dateRange[0]
  let startTime1 = YyMmDdToTimes(startTime)
  let startTime2 = formatTime(startTime1)
  let startTime3 = timesToYyMmDd1( startTime2 )
   let endTime = dateRange[1]
   let endTime1 = YyMmDdToTimes(endTime)
   let endTime2 = formatTime(endTime1)
  let endTime3 = endTime2 + 24 * 60 * 60 * 1000 - 1
  let endTime4 = timesToYyMmDd1( endTime3 )
  return {
    startTime:startTime3,endTime:endTime4
  }
}

const formatTime = (timestamp) => {
  let time = new Date(timestamp)
  let stTime = timestamp - time.getHours() * 60 * 60 * 1000 - time.getMinutes() * 60 * 1000 - time.getSeconds() * 1000 - time.getMilliseconds();
  return stTime
}

export {
  YyMmDdToTimes,timesToYyMmDd1,getDay,getEndStartTime,
}
